//  @ Project : GagalPanen
//  @ File Name : sicklesprite.cpp
//  @ Date : 3/9/2011
//  @ Author : Irvan
//
//


#include "sicklesprite.hpp"
#include "spritesconstants.hpp"
#include "gamemaps.hpp"
#include "creatures.hpp"
#include "spritetype.hpp"

SickleSprite::SickleSprite(GameInterface* game) :
    Sprite(game, SpritesConstants::sickleSpriteStartLocationXCoordinate(),
                 SpritesConstants::sickleSpriteStartLocationYCoordinate()) {
  return;
}

SickleSprite::SickleSprite(GameInterface* game, std::ifstream& is) :
    Sprite(game, is) {
}

void SickleSprite::save(std::ofstream& os) {
  Sprite::save(os);
}

SickleSprite::~SickleSprite() {
  return;
}

void SickleSprite::resetPosition() {
  setLocation(
          game_->getMaps()->getField()->getCellAt(
          SpritesConstants::sickleSpriteStartLocationXCoordinate(),
          SpritesConstants::sickleSpriteStartLocationYCoordinate()));
  return;
}

bool SickleSprite::isImportant(Cell* cell) {
    if (!cell->isPlantable()) {
    return false;
  }
  PlantableCell* pc = (PlantableCell*) cell;
  if (game_->getCreatures()->getPlants()->containsPlantAt(pc)) {
    Plant* plant = game_->getCreatures()->getPlants()->getPlantAt(pc);
    return plant->isDead();
  }
  return false;
}

SpriteType SickleSprite::getType() {
  return kSickle;
}

std::string SickleSprite::getViewRep(Direction dir) {
  return SpritesConstants::getSickleSpriteRep(dir);
}

ActionType SickleSprite::getActionType() {
  return kActionSickle;
}
